package com.zhengyuedong.bbs.core.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Topic entity.
 * 
 * @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "topic", catalog = "yd_bbs_db")
public class Topic implements java.io.Serializable {

	// Fields

	private Long id;
	private Node node;
	private User user;
	private String title;
	private String content;
	private Date createTime;
	private Date createTimeGmt;
	private String excerpt;
	private String status;
	private Date updateTime;
	private Date updateTimeGmt;
	private Long commentCount;
	private String commentStatus;
	private String alias;
	private Long clickCount;
	private Set<Comment> comments = new HashSet<Comment>(0);

	// Constructors

	/** default constructor */
	public Topic() {
	}

	/** full constructor */
	public Topic(Node node, User user, String title, String content,
			Date createTime, Date createTimeGmt, String excerpt, String status,
			Date updateTime, Date updateTimeGmt, Long commentCount,
			String commentStatus, String alias, Long clickCount,
			Set<Comment> comments) {
		this.node = node;
		this.user = user;
		this.title = title;
		this.content = content;
		this.createTime = createTime;
		this.createTimeGmt = createTimeGmt;
		this.excerpt = excerpt;
		this.status = status;
		this.updateTime = updateTime;
		this.updateTimeGmt = updateTimeGmt;
		this.commentCount = commentCount;
		this.commentStatus = commentStatus;
		this.alias = alias;
		this.clickCount = clickCount;
		this.comments = comments;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "node_id")
	public Node getNode() {
		return this.node;
	}

	public void setNode(Node node) {
		this.node = node;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "author_user_id")
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "title", length = 65535)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "content")
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "create_time", length = 0)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "create_time_gmt", length = 0)
	public Date getCreateTimeGmt() {
		return this.createTimeGmt;
	}

	public void setCreateTimeGmt(Date createTimeGmt) {
		this.createTimeGmt = createTimeGmt;
	}

	@Column(name = "excerpt", length = 65535)
	public String getExcerpt() {
		return this.excerpt;
	}

	public void setExcerpt(String excerpt) {
		this.excerpt = excerpt;
	}

	@Column(name = "status", length = 20)
	public String getStatus() {
		return this.status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "update_time", length = 0)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "update_time_gmt", length = 0)
	public Date getUpdateTimeGmt() {
		return this.updateTimeGmt;
	}

	public void setUpdateTimeGmt(Date updateTimeGmt) {
		this.updateTimeGmt = updateTimeGmt;
	}

	@Column(name = "comment_count")
	public Long getCommentCount() {
		return this.commentCount;
	}

	public void setCommentCount(Long commentCount) {
		this.commentCount = commentCount;
	}

	@Column(name = "comment_status", length = 20)
	public String getCommentStatus() {
		return this.commentStatus;
	}

	public void setCommentStatus(String commentStatus) {
		this.commentStatus = commentStatus;
	}

	@Column(name = "alias", length = 200)
	public String getAlias() {
		return this.alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	@Column(name = "click_count")
	public Long getClickCount() {
		return this.clickCount;
	}

	public void setClickCount(Long clickCount) {
		this.clickCount = clickCount;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "topic")
	public Set<Comment> getComments() {
		return this.comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

}